# 清理和重新安装依赖脚本

Write-Host "开始清理项目..." -ForegroundColor Green

# 1. 删除 node_modules
if (Test-Path "node_modules") {
    Write-Host "删除 node_modules..." -ForegroundColor Yellow
    Remove-Item -Recurse -Force "node_modules"
}

# 2. 删除 package-lock.json
if (Test-Path "package-lock.json") {
    Write-Host "删除 package-lock.json..." -ForegroundColor Yellow
    Remove-Item -Force "package-lock.json"
}

# 3. 删除 unpackage
if (Test-Path "unpackage") {
    Write-Host "删除 unpackage..." -ForegroundColor Yellow
    Remove-Item -Recurse -Force "unpackage"
}

# 4. 清理 npm 缓存
Write-Host "清理 npm 缓存..." -ForegroundColor Yellow
npm cache clean --force

# 5. 检查 Node.js 版本
Write-Host "`n检查 Node.js 版本..." -ForegroundColor Green
node -v
npm -v

# 6. 重新安装依赖
Write-Host "`n重新安装依赖..." -ForegroundColor Green
npm install

Write-Host "`n完成！现在可以运行项目了。" -ForegroundColor Green
Write-Host "运行微信小程序: npm run dev:mp-weixin" -ForegroundColor Cyan
Write-Host "运行 H5: npm run dev:h5" -ForegroundColor Cyan
